﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace _2301MVCDemo.Controllers
{
    public class TestController : Controller
    {
        // GET: Test
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]//特性
        public ActionResult Index(string uname,int? uage)
        {
            ViewBag.uname = uname;
            ViewBag.uage = uage;
            return View();
        }

        public ActionResult UploadImg(HttpPostedFileBase file)
        {
            if (file != null)
            {
                if (file.ContentLength != 0)
                {
                    file.SaveAs(Server.MapPath("~/UploadFiles/"+file.FileName));
                    ViewBag.imgpath = "/UploadFiles/" + file.FileName;
                }
            }
            
            return View("UploadImage");
        }
    }
}